WorkerScript.onMessage = function(message) {
    doAddToCollection(message);
}


function doAddToCollection(message) {
    var xhr = new XMLHttpRequest;
    var url = "https://production-2.sogeoapi.com/api/poi/" + message.spotId + "/black/book?oauth_token=" + message.token;
    try {
        xhr.open("DELETE", url);
        xhr.onreadystatechange = function() {
            netLog(url, xhr.responseText);
            if (xhr.readyState == XMLHttpRequest.DONE) {
                var response = JSON.parse(xhr.responseText);
                WorkerScript.sendMessage({ 'spotId': message.spotId, 'removed': true });
            }
        }
        xhr.send();
    } catch(err) {
        // DELETE is unsupported so far.... workaround anyone? :-(
        console.log(err)
    }
}
